package com.jianan.mis.data.domain.base;

import java.io.Serializable;


/**
 * This is an object that contains data related to the groups table.
 * Do not modify this class because it will be overwritten if the configuration file
 * related to this class is modified.
 *
 * @hibernate.class
 *  table="groups"
 */

public abstract class BaseGroup  implements Serializable {

	public static String REF = "Group";
	public static String PROP_NAME = "Name";
	public static String PROP_ID = "Id";
	public static String PROP_CODE = "Code";


	// constructors
	public BaseGroup () {
		initialize();
	}

	/**
	 * Constructor for primary key
	 */
	public BaseGroup (java.lang.Integer id) {
		this.setId(id);
		initialize();
	}

	protected void initialize () {}



	private int hashCode = Integer.MIN_VALUE;

	// primary key
	private java.lang.Integer id;

	// fields
	private java.lang.String name;
	private java.lang.String code;

	// collections
	private java.util.Set<com.jianan.mis.data.domain.View> views;
	private java.util.Set<com.jianan.mis.data.domain.Employee> employees;



	/**
	 * Return the unique identifier of this class
     * @hibernate.id
     *  generator-class="native"
     *  column="id"
     */
	public java.lang.Integer getId () {
		return id;
	}

	/**
	 * Set the unique identifier of this class
	 * @param id the new ID
	 */
	public void setId (java.lang.Integer id) {
		this.id = id;
		this.hashCode = Integer.MIN_VALUE;
	}




	/**
	 * Return the value associated with the column: name
	 */
	public java.lang.String getName () {
		return name;
	}

	/**
	 * Set the value related to the column: name
	 * @param name the name value
	 */
	public void setName (java.lang.String name) {
		this.name = name;
	}



	/**
	 * Return the value associated with the column: code
	 */
	public java.lang.String getCode () {
		return code;
	}

	/**
	 * Set the value related to the column: code
	 * @param code the code value
	 */
	public void setCode (java.lang.String code) {
		this.code = code;
	}



	/**
	 * Return the value associated with the column: Views
	 */
	public java.util.Set<com.jianan.mis.data.domain.View> getViews () {
		return views;
	}

	/**
	 * Set the value related to the column: Views
	 * @param views the Views value
	 */
	public void setViews (java.util.Set<com.jianan.mis.data.domain.View> views) {
		this.views = views;
	}

	public void addToViews (com.jianan.mis.data.domain.View view) {
		if (null == getViews()) setViews(new java.util.TreeSet<com.jianan.mis.data.domain.View>());
		getViews().add(view);
	}



	/**
	 * Return the value associated with the column: Employees
	 */
	public java.util.Set<com.jianan.mis.data.domain.Employee> getEmployees () {
		return employees;
	}

	/**
	 * Set the value related to the column: Employees
	 * @param employees the Employees value
	 */
	public void setEmployees (java.util.Set<com.jianan.mis.data.domain.Employee> employees) {
		this.employees = employees;
	}

	public void addToEmployees (com.jianan.mis.data.domain.Employee employee) {
		if (null == getEmployees()) setEmployees(new java.util.TreeSet<com.jianan.mis.data.domain.Employee>());
		getEmployees().add(employee);
	}




	public boolean equals (Object obj) {
		if (null == obj) return false;
		if (!(obj instanceof com.jianan.mis.data.domain.Group)) return false;
		else {
			com.jianan.mis.data.domain.Group group = (com.jianan.mis.data.domain.Group) obj;
			if (null == this.getId() || null == group.getId()) return false;
			else return (this.getId().equals(group.getId()));
		}
	}

	public int hashCode () {
		if (Integer.MIN_VALUE == this.hashCode) {
			if (null == this.getId()) return super.hashCode();
			else {
				String hashStr = this.getClass().getName() + ":" + this.getId().hashCode();
				this.hashCode = hashStr.hashCode();
			}
		}
		return this.hashCode;
	}


	public String toString () {
		return super.toString();
	}


}